package com.gitee.form_token.service.impl;

import com.gitee.form_token.dto.MenuDto;
import com.gitee.form_token.entity.SysResource;
import com.gitee.form_token.mapper.SysResourceMapper;
import com.gitee.form_token.service.SysResourceService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 资源表 服务实现类
 * </p>
 *
 * @author Saturn
 * @since 2024-10-30
 */
@Service
public class SysResourceServiceImpl extends ServiceImpl<SysResourceMapper, SysResource> implements SysResourceService {

    // 菜单列表 || 根据角色ID
    @Override
    public List<MenuDto> menuByRoleId(Long roleId) {

        QueryWrapper<SysResource> wrapper = Wrappers.query();
        wrapper.eq("rr.role_id", roleId).orderByAsc("re.sort");
        List<MenuDto> list = baseMapper.listResource(wrapper);

        return list;
    }


}
